<?php
require("../../../libraries/config.php");
require("../../../libraries/dbclass2.php");
require("../../../libraries/function.php");
//Manga fucntoion----------------

function manga_delete($xcrud)
{
    if ($xcrud->get('primary'))
    {
        $db = Xcrud_db::get_instance();
		$sql="select xoa from anime where id=". (int)$xcrud->get('primary');
		$db->query($sql);
		$r1=$db->row();
			if($r1['xoa']==0){
				 $query = 'UPDATE anime SET `xoa` = 1 WHERE id = ' . (int)$xcrud->get('primary');
			}else{
				  $query = 'UPDATE anime SET `xoa` = 0 WHERE id = ' . (int)$xcrud->get('primary');
			}
        $db->query($query);
    }
}

function manga_pass($xcrud)
{
    if ($xcrud->get('primary'))
    {
        $db = Xcrud_db::get_instance();
		$sql="select duyet from anime where id=". (int)$xcrud->get('primary');
		$db->query($sql);
		$r1=$db->row();
			if($r1['duyet']==0){
      		  $query = 'UPDATE anime SET `duyet` = 1 WHERE id = ' . (int)$xcrud->get('primary');
			}else{
			 $query = 'UPDATE anime SET `duyet` = 0 WHERE id = ' . (int)$xcrud->get('primary');
			}
        $db->query($query);
    }
}



function manga_pass_adult($xcrud)
{
    if ($xcrud->get('primary'))
    {
        $db = Xcrud_db::get_instance();
		$sql="select adult from anime where id=". (int)$xcrud->get('primary');
		$db->query($sql);
		$r1=$db->row();
			if($r1['adult']==0){
      		  $query = 'UPDATE anime SET `adult` = 1 WHERE id = ' . (int)$xcrud->get('primary');
			}else{
			 $query = 'UPDATE anime SET `adult` = 0 WHERE id = ' . (int)$xcrud->get('primary');
			}
        $db->query($query);
    }
}

function manga_pick($xcrud)
{
    if ($xcrud->get('primary'))
    {
        $db = Xcrud_db::get_instance();
		$sql="select pick from anime where id=". (int)$xcrud->get('primary');
		$db->query($sql);
		$r1=$db->row();
			if($r1['pick']==0){
      		  $query = 'UPDATE anime SET `pick` = 1 WHERE id = ' . (int)$xcrud->get('primary');
			}else{
			 $query = 'UPDATE anime SET `pick` = 0 WHERE id = ' . (int)$xcrud->get('primary');
			}
        $db->query($query);
    }
}



function manga_pick_episode($xcrud)
{
    if ($xcrud->get('primary'))
    {
        $db = Xcrud_db::get_instance();
		$sql="select home from chapterk2 where id=". (int)$xcrud->get('primary');
		$db->query($sql);
		$r1=$db->row();
			if($r1['home']==0){
      		  $query = 'UPDATE chapterk2 SET `home` = 1 WHERE id = ' . (int)$xcrud->get('primary');
			}else{
			 $query = 'UPDATE chapterk2 SET `home` = 0 WHERE id = ' . (int)$xcrud->get('primary');
			}
        $db->query($query);
    }
}
function manga_delete_episode($xcrud)
{
    if ($xcrud->get('primary'))
    {
        $db = Xcrud_db::get_instance();
		$sql="select xoa from chapterk2 where id=". (int)$xcrud->get('primary');
		$db->query($sql);
		$r1=$db->row();
			if($r1['xoa']==0){
      		  $query = 'UPDATE chapterk2 SET `xoa` = 1 WHERE id = ' . (int)$xcrud->get('primary');
			}else{
			 $query = 'UPDATE chapterk2 SET `xoa` = 0 WHERE id = ' . (int)$xcrud->get('primary');
			}
        $db->query($query);
    }
}





function delete_report($xcrud)
{
    if ($xcrud->get('postid'))
    {
		
		$db = Xcrud_db::get_instance();
        $query = 'update report_post set xuly=1 WHERE id = ' . (int)$xcrud->get('primary');
        $db->query($query);
	//	xcrud_remove_post_report((int)$xcrud->get('postid'));
		xcrud_remove_post_report($xcrud->get('postid'));
	
		
      
    }
}

function manga_xulyreport($xcrud)
{
    if ($xcrud->get('primary'))
    {
		
		$db = Xcrud_db::get_instance();
		
        $query = 'update report_truyen set xuly=1,xuly_username="'.$_SESSION['user']['username'].'" WHERE id = ' . (int)$xcrud->get('primary');
        $db->query($query);
	//	xcrud_remove_post_report((int)$xcrud->get('postid'));
	
		
      
    }
}


function manga_duyetupload($xcrud)
{
    if ($xcrud->get('primary'))
    {
		$db = Xcrud_db::get_instance();
        $query = 'update register_upload set duyet=1 WHERE id = ' . (int)$xcrud->get('primary');
        $db->query($query);
		$query = 'update users set upload=1 WHERE username = "'.$xcrud->get('user').'"';
        $db->query($query);
   
    }
}

function manga_picasa_pass_album($xcrud){
		  $db = Xcrud_db::get_instance();
		$sql="select status from picasa_album where id=". (int)$xcrud->get('primary');
		$db->query($sql);
		$r1=$db->row();
			if($r1['status']==0){
      		  $query = 'UPDATE picasa_album SET `status` = 1 WHERE id = ' . (int)$xcrud->get('primary');
			}else{
			 $query = 'UPDATE picasa_album SET `status` = 0 WHERE id = ' . (int)$xcrud->get('primary');
			}
        $db->query($query);
}


//-------------------- BLOG ACTION ----------------------------------------
function blog_pass_video($xcrud){
		  $db = Xcrud_db::get_instance();
		$sql="select status from blog_video where id=". (int)$xcrud->get('primary');
		$db->query($sql);
		$r1=$db->row();
			if($r1['status']==0){
      		  $query = 'UPDATE blog_video SET `status` = 1 WHERE id = ' . (int)$xcrud->get('primary');
			}else{
			 $query = 'UPDATE blog_video SET `status` = 0 WHERE id = ' . (int)$xcrud->get('primary');
			}
        $db->query($query);
}
function blog_pick_video($xcrud){
		  $db = Xcrud_db::get_instance();
		$sql="select pick from blog_video where id=". (int)$xcrud->get('primary');
		$db->query($sql);
		$r1=$db->row();
			if($r1['pick']==0){
      		  $query = 'UPDATE blog_video SET `pick` = 1 WHERE id = ' . (int)$xcrud->get('primary');
			}else{
			 $query = 'UPDATE blog_video SET `pick` = 0 WHERE id = ' . (int)$xcrud->get('primary');
			}
        $db->query($query);
}

function blog_pass_post($xcrud){
		  $db = Xcrud_db::get_instance();
		$sql="select status from blog_post where id=". (int)$xcrud->get('primary');
		$db->query($sql);
		$r1=$db->row();
			if($r1['status']==0){
      		  $query = 'UPDATE blog_post SET `status` = 1 WHERE id = ' . (int)$xcrud->get('primary');
			}else{
			 $query = 'UPDATE blog_post SET `status` = 0 WHERE id = ' . (int)$xcrud->get('primary');
			}
        $db->query($query);
}


function blog_pass_hide_comment($xcrud){
		  $db = Xcrud_db::get_instance();
		$sql="select hide from blog_comment where id=". (int)$xcrud->get('primary');
		$db->query($sql);
		$r1=$db->row();
			if($r1['hide']==0){
      		  $query = 'UPDATE blog_comment SET `hide` = 1 WHERE id = ' . (int)$xcrud->get('primary');
			}else{
			 $query = 'UPDATE blog_comment SET `hide` = 0 WHERE id = ' . (int)$xcrud->get('primary');
			}
        $db->query($query);
}

function blog_pick_post_home($xcrud){
		  $db = Xcrud_db::get_instance();
		$sql="select pick_home from blog_post where id=". (int)$xcrud->get('primary');
		$db->query($sql);
		$r1=$db->row();
			if($r1['pick_home']==0){
      		  $query = 'UPDATE blog_post SET `pick_home` = 1 WHERE id = ' . (int)$xcrud->get('primary');
			}else{
			 $query = 'UPDATE blog_post SET `pick_home` = 0 WHERE id = ' . (int)$xcrud->get('primary');
			}
        $db->query($query);
}
function blog_pick_post_category($xcrud){
		  $db = Xcrud_db::get_instance();
		$sql="select pick_category from blog_post where id=". (int)$xcrud->get('primary');
		$db->query($sql);
		$r1=$db->row();
			if($r1['pick_category']==0){
      		  $query = 'UPDATE blog_post SET `pick_category` = 1 WHERE id = ' . (int)$xcrud->get('primary');
			}else{
			 $query = 'UPDATE blog_post SET `pick_category` = 0 WHERE id = ' . (int)$xcrud->get('primary');
			}
        $db->query($query);
}
function blog_pick_post_subcategory($xcrud){
		  $db = Xcrud_db::get_instance();
		$sql="select pick_subcategory from blog_post where id=". (int)$xcrud->get('primary');
		$db->query($sql);
		$r1=$db->row();
			if($r1['pick_subcategory']==0){
      		  $query = 'UPDATE blog_post SET `pick_subcategory` = 1 WHERE id = ' . (int)$xcrud->get('primary');
			}else{
			 $query = 'UPDATE blog_post SET `pick_subcategory` = 0 WHERE id = ' . (int)$xcrud->get('primary');
			}
        $db->query($query);
}
?>
